package com.iring.exception;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;

import com.google.gson.Gson;
import com.iring.exception.config.ERRVO;
import com.iring.exception.config.ErrorEnum;


/**
 * 访问资源不允许访问的异常
 *
 * @author wanggan
 */
@ResponseStatus(HttpStatus.FORBIDDEN)
public class NotAllowedException extends RuntimeException {

    private static final long serialVersionUID = -1438773650530788214L;
    
    private static Gson gson = new Gson();
    
    public NotAllowedException() {
        super("Not aloowed to Access!");
    }

    public NotAllowedException(String message) {
        super(message);
    }

    public NotAllowedException(String code, String msg) {
        super(gson.toJson(new ERRVO(code, msg)));
    }

    public NotAllowedException(ErrorEnum errorEnum) {
        super(gson.toJson(new ERRVO(errorEnum.getCode(), errorEnum.getMsg())));
    }

}
